<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:p="http://primefaces.org/ui"
      xmlns:f="http://java.sun.com/jsf/core">

    <h:form id="frmTitle">
        <p:growl id="msgs" showDetail="false"/>
        <h:panelGrid columns="2" cellpadding="1">
            <h:outputText value="#{msgs.etapaTitulo}" styleClass="fontTitle"/>
        </h:panelGrid>
    </h:form>

    <h:form id="frmNew">

        <p:fieldset legend="#{msgs.etapaLgdNovo}">

            <h:panelGrid columns="2" id="pngNew">    

                <p:outputLabel for="lblDescricao" value="#{msgs.descricao}"/>
                <h:panelGrid columns="2">     
                    <p:inputText id="lblDescricao" value="#{etapaNewMB.descricao}" size="45"/>
                </h:panelGrid>

                <p:outputLabel for="lblDepartamento" value="#{msgs.lblDepartamentoResponsavel}"/>
                <h:panelGrid columns="2">
                    <p:selectOneMenu id="lblDepartamento" binding="#{etapaNewMB.cmbDepartamento}" style="width: 150px">  
                        <f:selectItem itemValue="0" itemLabel="#{msgs.cmbSelecione}" />
                        <f:selectItems value="#{etapaNewMB.lsdepartamento}"/>
                        <p:ajax listener="#{etapaNewMB.selecionarDepartamento}"/>  
                    </p:selectOneMenu>    
                </h:panelGrid>

                <h:outputText value="#{msgs.processos}"/>
                <h:panelGrid columns="2" id="pngProcesso">  
                    <p:commandButton id="btnBuscarProcesso" onclick="dlgProcesso.show()" icon="ui-icon ui-icon-plus"/>
                </h:panelGrid>
                
                <h:outputText value="#{msgs.prazo}"/>
                <h:panelGrid columns="2">  
                    <p:spinner id="spinnerBasic" value="#{etapaNewMB.prazo}"/> 
                </h:panelGrid>

                <p:outputLabel for="lblStatus" value="#{msgs.status}"/>
                <h:panelGrid columns="3" id="pngStatus">     
                    <p:inputText id="lblStatus" value="#{etapaNewMB.strstatusdescricao}" size="45"/>
                    <p:commandButton id="btnBuscarStatus" oncomplete="dlgStatus.show()" icon="ui-icon ui-icon-search"/>
                    <p:commandButton id="btnRemoverStatus" actionListener="#{etapaNewMB.removerStatus}" rendered="#{etapaNewMB.statusselecionado != null}" icon="ui-icon ui-icon-close" update="pngStatus" />   
                </h:panelGrid>

                <h:panelGrid columns="2">
                    <p:commandButton id="btnSalvar" value="#{msgs.salvar}" action="#{etapaNewMB.salvar}" ajax="false"/>
                    <p:commandButton id="btnVoltar" value="#{msgs.voltar}" action="#{etapaNewMB.voltar}" ajax="false"/> 
                </h:panelGrid>
            </h:panelGrid>

        </p:fieldset>
    </h:form>

    <p:dialog header="#{msgs.dlgTituloStatus}" widgetVar="dlgStatus" width="750" resizable="false" modal="true" styleClass="styleDialog">

        <h:form id="frmStatus">

            <p:fieldset legend="#{msgs.dlgLgdTituloStatus}">

                <h:panelGrid columns="1" width="100%">

                    <h:panelGrid columns="2" >
                        <p:inputText id="txtStatusTitulo" value="#{etapaNewMB.statusbusca}" size="40"/>
                        <p:commandButton id="btnBuscar" actionListener="#{etapaNewMB.buscarStatus}" update=":frmStatus:tblStatus" icon="ui-icon ui-icon-search"/>                    
                    </h:panelGrid>

                    <p:dataTable id="tblStatus" var="tbl" value="#{etapaNewMB.lsstatus}" rows="5" paginator="true"
                                 emptyMessage="#{msgs.msgTabelaVazia}" paginatorPosition="bottom">  

                        <f:facet name="header">
                            <h:outputText value="#{msgs.statusTblTitulo}"/>                    
                        </f:facet>

                        <p:column>
                            <f:facet name="header">
                                <h:outputText value="#{msgs.descricao}"/>
                            </f:facet>
                            <h:outputText value="#{tbl.descricao}"/>
                        </p:column>

                        <p:column>
                            <f:facet name="header">
                                <h:outputText value="#{msgs.status}"/>
                            </f:facet>
                            <h:outputText value="#{etapaNewMB.strStatusLabel(tbl.status)}"/>
                        </p:column>

                        <p:column>
                            <p:commandButton id="btnSelecionarStatus" icon="ui-icon ui-icon-check" actionListener="#{etapaNewMB.selecionarStatus(tbl)}" onclick="dlgStatus.hide()" update=":frmStatus, :frmNew:pngStatus"/>
                        </p:column>

                    </p:dataTable>  

                </h:panelGrid>

            </p:fieldset>
            <p:commandButton id="btnFechar" value="#{msgs.btnFechar}" onclick="dlgModelo.hide()" style="width:90px;margin-bottom: 20px;" styleClass="centerButton"/>

        </h:form>

    </p:dialog>

    <p:dialog header="#{msgs.dlgTituloProcesso}" widgetVar="dlgProcesso" width="750" resizable="false" modal="true" styleClass="styleDialog">

        <h:form id="frmProcesso">

            <p:fieldset legend="#{msgs.dlgLgdTituloProcesso}">
                <p:commandButton id="btnAddProcessos" value="#{msgs.adicionarProcessos}" onclick="dlgSearchProcesso.show()"/>
            </p:fieldset>

            <p:fieldset legend="#{msgs.dlgLgdTituloProcesso}">

                <h:panelGrid columns="1" width="100%">

                    <p:dataTable id="tblProcessoAdd" var="tbl" value="#{etapaNewMB.lsprocessoadd}" rows="5" paginator="true"
                                 emptyMessage="#{msgs.msgTabelaVazia}" paginatorPosition="bottom">  

                        <f:facet name="header">
                            <h:outputText value="#{msgs.processoTblTitulo}"/>                    
                        </f:facet>

                        <p:column>
                            <f:facet name="header">
                                <h:outputText value="#{msgs.orientacao}"/>
                            </f:facet>
                            <h:outputText value="#{tbl.orientacao}"/>
                        </p:column>

                        <p:column>
                            <p:commandButton id="btnRemoverProcesso" actionListener="#{etapaNewMB.removerProcesso(tbl)}" rendered="#{etapaNewMB.lsprocessoadd.size() > 0}" icon="ui-icon ui-icon-close" update=":frmProcesso" />   
                        </p:column>

                    </p:dataTable>  

                    <h:panelGrid>
                        <p:commandButton id="btnFechar" value="#{msgs.btnFechar}" onclick="dlgProcesso.hide()" style="width:90px;margin-bottom: 20px;" styleClass="centerButton"/>
                    </h:panelGrid>

                </h:panelGrid>

            </p:fieldset>

        </h:form>

    </p:dialog>


    <p:dialog header="#{msgs.dlgTituloProcesso}" widgetVar="dlgSearchProcesso" width="750" resizable="false" modal="true" styleClass="styleDialog">

        <h:form id="frmSearchProcesso">

            <p:fieldset legend="#{msgs.dlgLgdTituloProcesso}">

                <h:panelGrid columns="1" width="100%">

                    <h:panelGrid columns="2" >
                        <p:inputText id="txtProcessoTitulo" value="#{etapaNewMB.processobusca}" size="40"/>
                        <p:commandButton id="btnBuscar" actionListener="#{etapaNewMB.buscarProcesso}" update=":frmSearchProcesso:tblProcesso" icon="ui-icon ui-icon-search"/>                    
                    </h:panelGrid>

                    <p:dataTable id="tblProcesso" var="tbl" value="#{etapaNewMB.lsprocesso}" rows="5" paginator="true"
                                 emptyMessage="#{msgs.msgTabelaVazia}" paginatorPosition="bottom">  

                        <f:facet name="header">
                            <h:outputText value="#{msgs.processoTblTitulo}"/>                    
                        </f:facet>

                        <p:column>
                            <f:facet name="header">
                                <h:outputText value="#{msgs.orientacao}"/>
                            </f:facet>
                            <h:outputText value="#{tbl.orientacao}"/>
                        </p:column>

                        <p:column>
                            <p:commandButton id="btnSelecionarProcesso" icon="ui-icon ui-icon-check" actionListener="#{etapaNewMB.selecionarProcesso(tbl)}" update=":frmProcesso, :frmSearchProcesso"/>
                        </p:column>

                    </p:dataTable>

                    <h:panelGrid style="text-align: center">
                        <p:commandButton id="btnFecharSearchP" value="#{msgs.btnFechar}" onclick="dlgSearchProcesso.hide()" style="width:90px;margin-bottom: 20px;" styleClass="centerButton"/>
                    </h:panelGrid>
                </h:panelGrid>

            </p:fieldset>

        </h:form>                

    </p:dialog>

</html>

